<template>
    <div class="demo">
        <h2>学校名称：{{name}}</h2>
        <h2>学校地址：{{address}}</h2>
    </div>
</template>

<script>
import pubsub from 'pubsub-js';
export default {
    name:'School',
    data(){
        return {
            name:'尚硅谷',
            address:'北京昌平',
            pubid: null
        }
    },
    mounted() {
        // this.$bus.$on('hello', (data)=>{
        //     console.log('school 组件收到了data: ', data)
        // })

        this.pubid = pubsub.subscribe('hello', (msgName, data)=>{
            console.log('有人调用了...',this, msgName, data);
        })
    },
    beforeDestroy() {
        // this.$bus.$off('hello')
        pubsub.unsubscribe(this.pubid)
    }
}
</script>

<style>
.demo{
    background-color: orange;
}
</style>
